package cn.wolfcode.rbac.web.intercptor;

import cn.wolfcode.rbac.domain.Employee;
import cn.wolfcode.rbac.util.RequiredPermission;
import cn.wolfcode.rbac.util.UserContext;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collection;

public class CheckLoginIntercptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        Employee current = UserContext.getCurrent();
        if (current == null) {
            response.sendRedirect("/login.jsp");
            return false;
        }
        return true;
    }


}
